.TH std::remove_pointer 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::remove_pointer \- std::remove_pointer

.SH Synopsis
   Defined in header <type_traits>
   template< class T >              \fI(since C++11)\fP
   struct remove_pointer;

   Provides the member typedef type which is the type pointed to by T, or, if T is not
   a pointer, then type is the same as T.

   If the program adds specializations for std::remove_pointer, the behavior is
   undefined.

.SH Member types

   Name Definition
   type the type pointed to by T or T if it's not a pointer

.SH Helper types

   template< class T >                                         \fI(since C++14)\fP
   using remove_pointer_t = typename remove_pointer<T>::type;

.SH Possible implementation

   template<class T> struct remove_pointer { typedef T type; };
   template<class T> struct remove_pointer<T*> { typedef T type; };
   template<class T> struct remove_pointer<T* const> { typedef T type; };
   template<class T> struct remove_pointer<T* volatile> { typedef T type; };
   template<class T> struct remove_pointer<T* const volatile> { typedef T type; };

.SH Example


// Run this code

 #include <type_traits>

 static_assert
 (
     std::is_same_v<int, int> == true &&
     std::is_same_v<int, int*> == false &&
     std::is_same_v<int, int**> == false &&
     std::is_same_v<int, std::remove_pointer_t<int>> == true &&
     std::is_same_v<int, std::remove_pointer_t<int*>> == true &&
     std::is_same_v<int, std::remove_pointer_t<int**>> == false &&
     std::is_same_v<int, std::remove_pointer_t<int* const>> == true &&
     std::is_same_v<int, std::remove_pointer_t<int* volatile>> == true &&
     std::is_same_v<int, std::remove_pointer_t<int* const volatile>> == true
 );

 int main() {}

.SH See also

   is_pointer  checks if a type is a pointer type
   \fI(C++11)\fP     \fI(class template)\fP
   add_pointer adds a pointer to the given type
   \fI(C++11)\fP     \fI(class template)\fP
